import { RegisterComponent } from "@feng3d/ecs";
import { Color, PointLightHelper } from "../../thirdparty/three/imports";
import { Component3D } from "../core/Component3D";
import { PointLight3D } from "../lights/PointLight3D";

declare module "@feng3d/ecs"
{
    interface ComponentMap { PointLightHelper3D: PointLightHelper3D; }
}

/**
 * 包装`three`中`PointLightHelper`。
 */
@RegisterComponent({ name: 'PointLightHelper3D' })
export class PointLightHelper3D extends Component3D
{
    _helper: PointLightHelper;

    light: PointLight3D;
    sphereSize?: number;
    color?: Color;

    init()
    {
        super.init();
        this._helper = new PointLightHelper(this.light._light, this.sphereSize, this.color);

        this._entity._group.add(this._helper);
    }

    destroy(): void
    {
        this._entity._group.remove(this._helper);

        this._helper.dispose();
        this._helper = null;

        super.destroy();
    }
}
